<!-- 分页链接 -->
{% if paginator.total_pages > 1 %}
  <div class="log pagination">
    <span class="log menu">
      {% if paginator.previous_page %}
        <a class="log button" href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}">上一页</a>
      {% endif %}

      {% assign start_pages = 1 | plus: 4 %}
      {% assign end_pages = paginator.total_pages | minus: 4 %}

      {% if paginator.page < start_pages %}

        {% for page in (1..start_pages) %}
          {% if page == paginator.page %}
            <a class="log button active">{{ page }}</a>
          {% elsif page == 1 %}
            <a class="log button segm" href="{{ site.baseurl | replace: '//', '/' }}"> 1 </a>
          {% else %}
            <a class="log button segm" href="{{ site.paginate_path | prepend: site.baseurl | replace: '//', '/' | replace: ':num', page }}">{{ page }}</a>
          {% endif %}
        {% endfor %}
        <a class="log button segm">...</a>
        <a class="log button segm" href="{{ site.paginate_path | prepend: site.baseurl | replace: '//', '/' | replace: ':num', paginator.total_pages }}">{{ paginator.total_pages }}</a>

      {% elsif paginator.page > end_pages %}

        <a class="log button segm" href="{{ site.baseurl | replace: '//', '/' }}"> 1 </a>
        <a class="log button segm">...</a>
        {% for page in (end_pages..paginator.total_pages) %}
          {% if page == paginator.page %}
            <a class="log button segm active">{{ page }}</a>
          {% else %}
            <a class="log button segm" href="{{ site.paginate_path | prepend: site.baseurl | replace: '//', '/' | replace: ':num', page }}">{{ page }}</a>
          {% endif %}
        {% endfor %}

      {% else %}

        <a class="log button segm" href="{{ site.baseurl | replace: '//', '/' }}"> 1 </a>
        <a class="log button segm">...</a>
        {% for page in (paginator.previous_page..paginator.next_page) %}
          {% if page == paginator.page %}
            <a class="log button segm active">{{ page }}</a>
          {% else %}
            <a class="log button segm" href="{{ site.paginate_path | prepend: site.baseurl | replace: '//', '/' | replace: ':num', page }}">{{ page }}</a>
          {% endif %}
        {% endfor %}
        <a class="log button segm">...</a>
        <a class="log button segm" href="{{ site.paginate_path | prepend: site.baseurl | replace: '//', '/' | replace: ':num', paginator.total_pages }}">{{ paginator.total_pages }}</a>

      {% endif %}

      {% if paginator.next_page %}
        <a class="log button segm" href="{{ paginator.next_page_path | prepend: site.baseurl | replace: '//', '/' }}">下一页</a>
      {% endif %}
    </span>
  </div>
{% endif %}
